package com.lcm.basic.p5.classz;

import java.util.Objects;

import static java.lang.System.out;

/**
 * @author Coder-lcm
 * @date 2021/3/31
 */
public class Person {
    private int id;
    private String name;

    public Person(){

    }

    public Person(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public void sayHello(String name){
        out.println("hello: " + name);
    }

    public void sendMsg(String target, String msg){
        out.println("send to  " + target + " : " + msg);
    }

    @Override
    public boolean equals(Object o) {
        if (o == null) {
            return false;
        }
        if (this == o) {
            return true;
        }
        if (o instanceof Person) {
            Person person = (Person) o;
            return id == person.id && name.equals(name);
        }
        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name);
    }
}
